
//
//  UILabel+Extension.swift
//  Weibo
//
//  Created by 张婷 on 15/10/16.
//  Copyright © 2015年 itheima. All rights reserved.
//

import UIKit

extension UILabel {
    
    ///  便利构造函数
    ///
    ///  - parameter title:       title
    ///  - parameter color:       字体颜色 默认深灰色
    ///  - parameter sizeFont:    字体大小 默认14号
    ///  - parameter screenInset: 相对屏幕的左右缩进 默认是0
    ///
    ///  - returns: 标签
    convenience init(title: String,
        color: UIColor = UIColor.darkGrayColor(),
        sizeFont: CGFloat = 14,
        screenInset: CGFloat = 0) {
            
            self.init()
            
            text = title
            textColor = color
            font = UIFont.systemFontOfSize(sizeFont)
            
            numberOfLines = 0
            
            if screenInset == 0 {
                textAlignment = .Center
            } else {
                textAlignment = .Left
                preferredMaxLayoutWidth = UIScreen.mainScreen().bounds.width - 2 * screenInset
            }
    }
}
